All Questions
7 questions
9votes
2answers
1kviews
Should function names describe their parameter types?
If you wish to perform the same action using different parameters, you can either make differently named functions: public Apple findAppleById(long id){ return repo.findById(id); } public Apple ...
2votes
5answers
1kviews
What should a constructor contain?
What should a constructor contain? In both cases, all three arguments are needed for the class to work. Which approach is better and why? 1) class Language { LanguageRepository ...
45votes
6answers
14kviews
Is it better to check `c >= '0'` or `c >= 48`?
After a discussion with some my colleagues, I've a 'philosophical' question about how treat the char data type in Java, following the best practices. Suppose a simple scenario (obviously this is only ...
1vote
2answers
7kviews
guideline on void methods that do not throw exceptions
In our codebase I saw a method that is similar to following: public void doSomething() { try { ... } catch (Exception e) { ... //log something ... } } The ...
34votes
8answers
15kviews
Is throwing an exception an anti-pattern here?
I just had a discussion over a design choice after a code review. I wonder what your opinions are. There's this Preferences class, which is a bucket for key-value pairs. Null values are legal (that'...
3votes
3answers
6kviews
articles in variable names and hard-coding strings
re-edited by author: no this is not 2 questions. This is one question about code review questions containing two separate points. Please do not edit my question. For naming variables, the two sides ...
3votes
2answers
3kviews
Is repeating links to the same class in a single javadoc comment a bad practice?
I'm currently writing an API and its documentation. For example I have something like this: public interface Event { } public interface Process { } public interface EventProcessor { /** * ...